package com.bdqn.ch05JD;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;

import java.util.Arrays;
import java.util.List;

/**
 * 游戏记录日志类
 */
public class GameLogger {
    private static final Logger logger = Logger.getLogger(GameLogger.class);
    public void before(JoinPoint jp) {
        logger.info("调用 " + jp.getTarget() + " 的 " + jp.getSignature().getName() + " 方法。方法入参：" + Arrays.toString(jp.getArgs()));
        List<Object> obj = Arrays.asList(jp.getArgs());
        Object objValue = obj.get(0);
        Equip equip = (Equip) objValue;
        if(equip.getType().equals("指环")) {
            equip.setName("紫色梦幻"+equip.getName());
            equip.setAttackPlus(equip.getAttackPlus() + 6);
            equip.setDefencePlus(equip.getDefencePlus() + 6);
            logger.info("参数修改后：装备名称：" + equip.getName() + "攻击力：" + equip.getAttackPlus()+"防御力：" + equip.getDefencePlus());
        }
    }
}
